<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('面试评价列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>应聘者姓名：</label>
                            <input type="text" name="interviewerName"/>
                        </li>
                        <li>
                            <label>所属部门：</label>
                            <input type="text" name="department"/>
                        </li>
                        <li>
                            <label>流程实例ID：</label>
                            <input type="text" name="instanceId"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()">
                <i class="fa fa-plus"></i> 添加
            </a>
            <!--<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="process:leave:export">
                <i class="fa fa-download"></i> 导出
             </a>-->
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />
<script th:src="@{/js/activiti.js}"></script>
<script th:inline="javascript">
    var prefix = ctx + "interview";
//    var datas = [[${@dict.getType('biz_leave_type')}]];
    var currentUser = [[${currentUser}]];

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "面试评价",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '主键ID',
                    visible: false
                },
                {
                    field: 'interviewerName',
                    title: '应聘者姓名'
                },
                {
                    field: 'sex',
                    title: '性别'
    },
        {
            field: 'age',
                title
        :
            '年龄'
        }
    ,
        {
            field: 'postId',
                title
        :
            '年龄'
        }
    ,
        {
            field: 'department',
                title
        :
            '所属部门'
        }
    ,
        {
            field: 'graduationInfo',
                title
        :
            '毕业信息'
        }
    ,
        {
            field: 'education',
                title
        :
            '学历'
        }
    ,
        {
            field: 'interviewTime',
                title
        :
            '应聘时间'
        }
    ,
        {
            field: 'factorOneResult',
                title
        :
            '求职动机评价结论'
        }
    ,
        {
            field: 'factorOneExplain',
                title
        :
            '求职动机简要说明'
        }
    ,
        {
            field: 'factorTwoResult',
                title
        :
            '仪表、仪态评价结论'
        }
    ,
        {
            field: 'factorTwoExplain',
                title
        :
            '仪表、仪态简要说明'
        }
    ,
        {
            field: 'factorThreeResult',
                title
        :
            '工资待遇、工作条件、满足程度评价结果'
        }
    ,
        {
            field: 'factorFourResult',
                title
        :
            '口头表达能力、沟通能力、反应能力评价结论'
        }
    ,
        {
            field: 'factorFiveResult',
                title
        :
            '工作经验与应聘职位的关联程度评价结论'
        }
    ,
        {
            field: 'factorSixResult',
                title
        :
            '学历、工作经历评价结论'
        }
    ,
        {
            field: 'factorThreeExplain',
                title
        :
            '工资待遇、工作条件、满足程度简要说明'
        }
    ,
        {
            field: 'factorFourExplain',
                title
        :
            '口头表达能力、沟通能力、反应能力简要说明'
        }
    ,
        {
            field: 'factorFiveExplain',
                title
        :
            '工作经验与应聘职位的关联程度简要说明'
        }
    ,
        {
            field: 'factorSixExplain',
                title
        :
            '学历、工作经历简要说明'
        }
    ,
        {
            field : 'instanceId',
                title
        :
            '流程实例ID'
        }
    ,
        {
            field: 'createBy',
                title
        :
            '创建人ID',
                visible
        :
            false
        }
    ,
        {
            field: 'createUserName',
                title
        :
            '创建人'
        }
    ,
        {
            field: 'applyUser',
                title
        :
            '申请人ID',
                visible
        :
            false
        }
    ,
        {
            field: 'applyUserName',
                title
        :
            '<span style="color: red;">申请人</span>',
                formatter
        :

            function (value, row, index) {
                return '<span style="color: red;">' + (value ? value : "-") + '</span>';
            }
        },
        {
            field: 'applyTime',
                title: '申请时间'
        },
        {
            field: 'taskId',
                title: '当前任务ID',
            visible: false
        },
        {
            field: 'taskName',
                title: '当前任务名称',
            align: 'center',
            formatter: function(value, row, index) {
            return '<span class="badge badge-primary">' + value + '</span>';
           }
        },
        {
            title: '操作',
                align: 'center',
            formatter: function(value, row, index) {
            var actions = [];
            if (row.instanceId) {
                actions.push('<a class="btn btn-primary btn-xs" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.id + '\')"><i class="fa fa-eye"></i> 表单数据</a> ');
                actions.push('<a class="btn btn-warning btn-xs" href="javascript:void(0)" onclick="showHistoryDialog(\'' + row.instanceId + '\')"><i class="fa fa-list"></i> 审批历史</a> ');
                actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="showProcessImgDialog(\'' + row.instanceId + '\')"><i class="fa fa-image"></i> 进度查看</a> ');
                if (row.taskName.indexOf('已结束') === -1) {
                    actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="cancelApply(\'' + row.instanceId + '\',\'' + row.createBy + '\')"><i class="fa fa-times"></i> 撤销</a> ');
                    var suspendOrActive = row.suspendState === '2' ? '激活' : '挂起';
                    var icon = row.suspendState === '2' ? 'fa fa-check' : 'fa fa-stop';
                    actions.push('<a class="btn btn-warning btn-xs" href="javascript:void(0)" onclick="suspendOrActiveApply(\'' + row.instanceId + '\',\'' + row.createBy + '\',\'' + row.suspendState + '\')"><i class="' + icon + '"></i> ' + suspendOrActive + '</a> ');
                }
            } else {
                actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="submitApply(\'' + row.id + '\',\'' + row.createBy + '\')"><i class="fa fa-user"></i> 提交申请</a> ');
                actions.push('<a class="btn btn-primary btn-xs" href="javascript:void(0)" onclick="editForm(\'' + row.id + '\',\'' + row.createBy + '\')"><i class="fa fa-edit"></i> 编辑</a> ');
                actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="removeForm(\'' + row.id + '\',\'' + row.createBy + '\')"><i class="fa fa-remove"></i> 删除</a>');
            }
            return actions.join('');
        }
        }]
    };
        $.table.init(options);
    });

    function submitApply(id, createBy) {
        $.modal.confirm("确认要提交申请吗?", function () {
            var url = prefix + "/submitApply";
            var data = {"id": id};
            $.operate.submit(url, "post", "json", data);
        });
    }

    function editForm(id, createBy) {
        $.operate.edit(id);
    }

    function removeForm(id, createBy) {
        $.operate.remove(id);
    }

    function cancelApply(instanceId, createBy) {
        $.modal.confirm("确认要撤销申请吗?", function () {
            var url = ctx + "process/cancelApply";
            var data = {"instanceId": instanceId};
            $.operate.submit(url, "post", "json", data);
        });
    }

    function suspendOrActiveApply(instanceId, createBy, suspendState) {
        var suspendOrActive = suspendState === '2' ? '激活' : '挂起';
        $.modal.confirm("确认要" + suspendOrActive + "申请吗?", function () {
            var url = ctx + "process/suspendOrActiveApply";
            var data = {"instanceId": instanceId, "suspendState": suspendState};
            $.operate.submit(url, "post", "json", data);
        });
    }
</script>
</body>
</html>